#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
void perm2(int* arr, int end, int limit)
{
	if (0 == end) {
		for (int i = 0; i < limit; ++i) printf("%d", arr[i]);
		printf("\n");
	}
	else
		for (int i = 0; i < limit; ++i) {
			if (!arr[i]) {
				arr[i] = end;
				perm2(arr, end - 1, limit);
				arr[i] = 0;
			}
		}
}
int main() {
	int n = 0;
	printf("input:");
	scanf("%d", &n);
	int* nums = (int*)malloc(sizeof(int) * n);
	for (int i = 0; i < n; ++i) nums[i] = 0;
	perm2(nums, n, n);

	return 0;
}